package com.example.forum.dao;

import com.example.forum.model.Article;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;

import java.util.List;

@Mapper
public interface ArticleMapper {
    int insert(Article row);

    int insertSelective(Article row);

    Article selectByPrimaryKey(Long id);

    int updateByPrimaryKeySelective(Article row);

    int updateByPrimaryKeyWithBLOBs(Article row);

    int updateByPrimaryKey(Article row);

    List<Article> selectByArticleName(String title);

    /**
     * date: 2024/09/14 13:17<br/>
     * Description:
     * 查询所有文章
     *
     * @author: jmy <br/>
     */
    List<Article> selectAll();

    /**
     * date: 2024/09/14 13:17<br/>
     * Description:
     *
     * @param boardId 板块id
     *                根据板块id查询所有该板块下的文章
     * @author: jmy <br/>
     */
    List<Article> selectAllByBoardId(Long boardId);

    /**
     * date: 2024/09/14 18:06<br/>
     * Description:根据帖子id查询
     *
     * @param id 帖子id
     * @author: jmy <br/>
     */
    Article selectDetailById(Long id);


    /**
     * date: 2024/09/14 18:53<br/>
     * Description:
     * 帖子浏览次数+1
     *
     * @param id 被浏览的帖子id
     * @author: jmy <br/>
     */
    int updateVisitCountById(@Param("id") Long id);


    /**
     * date: 2024/09/17 16:07<br/>
     * Description:
     * 用户个人中心，根据用户id查询帖子列表
     *
     * @param userId 用户id
     * @author: jmy <br/>
     */
    List<Article> selectByUserId(@Param("userId") Long userId);

    List<Article> selectByArticleContent(String key);
}